import React, { Component } from 'react'
import axios from 'axios';
export default class Weather extends Component {
    state = {
        city: '', 
        wea: []
    }
    render() {
        return (
            <div>
                城市: {this.state.city}
                <ul>
                    {this.state.wea.map((item, index) => {
                        return <li key={index}>{item.date}  {item.wea}</li>
                    })}
                </ul>
            </div>
        )
    }

    async componentDidMount(){
        let result = await axios.get('https://www.tianqiapi.com/api/?version=v1&city=%E5%8C%97%E4%BA%AC&appid=23941491&appsecret=TXoD5e8P');
        // console.log(result.data);
        this.setState({
            city: result.data.city,
            wea: result.data.data
        })
    }
}
